package com.swinginwind.flexutils.functions
{
	import flash.utils.Dictionary;

	/**
	 * @author jimmy
	 * @E-mail: swinginwind@gmail.com
	 * @version 1.0.0
	 * 创建时间：2013-5-10 上午9:56:27
	 * 
	 */
	public class UtilsWeb
	{
		public function UtilsWeb()
		{
		}
		
		public static function getParametersFromUrl(url:String):Dictionary
		{
			var resultMap:Dictionary = new Dictionary();
			var array1:Array = url.split("?");
			if(array1.length > 1)
			{
				var paraStr:String = array1[1].toString();
				var paraStrArray:Array = paraStr.split("&");
				for each(var str:String in paraStrArray)
				{
					var keyValArray:Array = str.split("=");
					if(keyValArray.length == 2)
					{
						resultMap[keyValArray[0]] = keyValArray[1];
					}
					else
						resultMap[keyValArray[0]] = null;
				}
			}
			return resultMap;
		}
		
		public static function getBasePathFromUrl(url:String):String
		{
			var array:Array = url.split("/");
			var pro:String = array[0];
			var ip:String = array[2];
			var context:String = "";
			if(array.length > 3)
			{
				context = array[3].split("?")[0];
			}
			return pro + "//" + ip + "/" + context;
		}
	}
}